import { PATH } from "./const.js";

function config(){
    return new JsonConfigFile(`${PATH.DATA}/config.json`, JSON.stringify({
        "ver": [2, 0, 0],
        "表单": {
            "物品": "minecraft:compass"
        },
        "坐标记录": {
            "数据格式": "json",
            "个人坐标数量上限": 64,
            "公共坐标数量上限": 128,
            "允许玩家记录公共坐标": true,
        },
        "额外功能": {
            "死亡坐标": {
                "启用通知": true,
                "启用回溯": false,
                "回溯价格": 0
            },
            "传送坐标": {
                "允许传送个人传送点": false,
                "允许记录个人传送点": false,
                "个人传送点上限": 99999,
                "个人传送价格": 0,
                "允许传送公共传送点": false,
                "允许记录公共传送点": false,
                "公共传送点上限": 99999,
                "公共传送价格": 0
            }
        },
        "经济系统": {
            "类型": "llmoney",
            "名称": "§r§e金币§r",
            "计分板名称": "money",
            "经济函数": {
                "namespace": "",
                "getMoney": "getMoney",
                "setMoney": "setMoney",
                "addMoney": "addMoney",
                "reduceMoney": "reduceMoney"
            }
        }
    }));
}

function xyz(format = 'json'){
    const default_xyz = {
        "ver": [2,0,0],
        "public" : {
            "默认": []
        },
        
        "person" : {}
    };
    // if (format != 'json'){
    //     const db = new KVDatabase(`${PATH.DATA}/xyz`);
    //     for (let key in default_xyz){
    //         db.set(key, default_xyz[key]);
    //     }
    //     return db;
    // }else{
        return new JsonConfigFile(`${PATH.DATA}/xyz.json`, JSON.stringify(default_xyz));
    //}
}

function playerInfo(){
    return new JsonConfigFile(`${PATH.DATA}/player.json`, JSON.stringify({
        ver: [2,0,0],
        players: {}
    }));
}

let config_json = config();

export const CONF_CONFIG = config_json;
export const XYZ_CONFIG = xyz(config_json.get("坐标记录")["数据格式"]);
export const PLAYERINFO_CONFIG = playerInfo();

// export const CONF = {
//     config : config_json,
//     xyz: xyz(config_json.get("坐标记录")["数据格式"]),
//     playerInfo: playerInfo()
// };